/***************************************************************************
 * 文件名：FMAddCentralPackage
 * 功能：
 * 说明：
 * -------------------------------------------------------------------------
 * 创建时间：2025/7/14 19:13:13
 * 创建人：葛浩
 * 邮箱： 2094733071@qq.com
 * =========================================================================
 *
 * 修改人：   
 * 修改时间：   
 * 修改说明：   
 ***************************************************************************/
using DevExpress.XtraEditors;
using System;
using System.Linq;

namespace ReferenceManagement
{
	public partial class FMAddCentralPackage : XtraForm
	{

		public string PackageName { get { return txtPackageName.Text ?? string.Empty; } }

		public string PackageVersion { get { return txtPackageVersion.Text ?? string.Empty; } }

		public string PackageType
		{
			get
			{
				var list = ReferenceTypeConst.GetList().Where(p => p.Value.Equals(cbxPackageType.SelectedItem?.ToString()));
				if (list?.Count() == 0)
				{
					return string.Empty;
				}

				return list.First().Value;
			}
		}

		private bool _isCreatingByCentralPkg;


		public FMAddCentralPackage(bool isCreateingByCentralPkg)
		{
			InitializeComponent();
			_isCreatingByCentralPkg = isCreateingByCentralPkg;
		}

		private void FMAddCentralPackage_Load(object sender, EventArgs e)
		{
			InitControl();
		}


		/// <summary>
		///初始化控件
		/// </summary>
		private void InitControl()
		{
			var list = ItemGroupTypeConst.GetList();
			if (list?.Count == 0)
			{
				return;
			}

			foreach(var item in list)
			{
				cbxPackageType.Properties.Items.Add(item.Value);
			}
		}


		private void btnConfirm_Click(object sender, EventArgs e)
		{
			DialogResult = System.Windows.Forms.DialogResult.OK;
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			DialogResult = System.Windows.Forms.DialogResult.Cancel;
		}

	}
}
